<template>
  <div class="box">
<el-dialog title="结账" :visible="flag" @close="btnCancel" >
<el-form :label-position="labelPosition" label-width="80px" :model="closingData" >
  <el-form-item label="姓名" style="width:50%;" >
    <el-input v-model="closingData.username" :disabled="true"></el-input>
  </el-form-item>
  <el-form-item label="房间号" prop="roomNum" style="width:50%;" >
    <el-input v-model="closingData.roomNum" :disabled="true"></el-input>
  </el-form-item>
  <el-form-item label="应退押金"  style="width:50%;" prop="deposit" >
    <el-input v-model="closingData.deposit" :disabled="true"></el-input>
  </el-form-item>
  <el-form-item label="总费用" prop="allmoney" style="width:50%;" >
    <el-input v-model="closingData.allmoney" :disabled="true"></el-input>
  </el-form-item>
  <el-row type="flex" justify="center">
    <el-col :span="8">
    <el-button type="primary" @click="btnOK">立即提交</el-button>
    <el-button @click="btnCancel">取消</el-button>
    </el-col>
  </el-row> 
   <!-- <el-form-item label="押金" style="width:50%;" prop="deposit">
    <el-input v-model="closingData.deposit"></el-input>
  <</el-form-item> -->
</el-form>
</el-dialog>
  </div>
</template>

<script>
import { addIncomePay } from '@/api/incomePay'
import { getRoomList,repairRoom } from '@/api/rooms'
import {inroom} from '@/api/users'
export default {
  data () {
    return {
      labelPosition: 'right',
        closingData: {}
    }
  },

  created () {
    // console.log(1);
    // console.log("this.pinfo",this.pinfo);
  },
  mounted () {

  },
  methods: {
btnCancel(){
    this.$emit('update:flag',false)
    },
  async  btnOK(){
      // console.log(this.closingData);
      await addIncomePay({income:this.closingData.allmoney,roomNum:this.closingData.roomNum,info:"入住收入",timeleave:this.closingData.leavetime})
      const room= await getRoomList({num_like:this.closingData.roomNum})
      await repairRoom({...room[0],state:3})
      // console.log(this);
      await inroom({...this.closingData,state:1})
      this.$parent.getUsersList()
      this.$message.success('结账成功')
      // console.log(this.pinfo);
      this.$parent.showDialogs=false
    }
  },
  props:{
    flag:{
        type:Boolean,
        default:false
    }
  }
}
</script>

<style>
  /* .box{
    position: relative;
    z-index:2000
  } */
</style>
